﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NhanAi.Entity;
using NhanAi.DAO;
namespace NhanAi.Public
{
    public partial class ExchangeAdd : PublicBasePage
    {
        //string message;
       // public string Message { get { return message; } }
        protected override void InitializeCulture()
        {
            base.InitializeCulture();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool rs = false;
            if (Request.HttpMethod == "POST" && Request["exchange"]!=null)
            {
                Validate(); if (IsValid)
                {
                    Post p = new Post();
                    PostDao dao = new PostDao();
                    p.Title = txtAuthor.Text;
                    p.TitleEn = txtEmail.Text;
                    p.Status = NhanAi.App_Code.NAConstants.POST_STA_DRAFT;
                    p.PostDate = DateTime.Now;
                    p.PostType = "qa";
                    p.PostAttribute = NhanAi.App_Code.NAConstants.POST_ATT_NEW;
                    p.ModifiedDate = DateTime.Now;
                    p.Guid = "";
                    p.Content = txtContent.Text;
                    p.ContentEn = "";
                    p.Excerpt = "";
                    p.ExcerptEn = "";
                    p.Name = "";
                    try
                    {
                        dao.Create(p);
                        //    message = GetGlobalResourceObject("HmLanguage", "submit_success").ToString();
                        rs = true;
                    }
                    catch (Exception ex)
                    {
                        //  message = GetGlobalResourceObject("HmLanguage", "comment_fail").ToString();
                    }
                }
                Response.Redirect("ExchangeAdd.aspx" + "?rs=" + (rs ? "success" : "false"));
             
            }
           
        }

   

       

    }
}